<?php
class form_total extends toba_ei_formulario
{
	//-----------------------------------------------------------------------------------
	//---- JAVASCRIPT -------------------------------------------------------------------
	//-----------------------------------------------------------------------------------

	function extender_objeto_js()
	{
		echo "
		//---- Procesamiento de EFs --------------------------------
		
		{$this->objeto_js}.ini = function(es_inicial)
		{
		
			var total = 0;
			var total_detalle = this.controlador.dep('form_guia_detalle').total('importe');
			
			alert(total_detalle);
					
			if(!es_inicial){
				
			
			  if (total_detalle != '' && total_detalle != null ){
					
				var total_concepto = this.controlador.dep('form_concepto_envio').total('importe');
			
				if (total_concepto != '' && total_concepto!= null ) {
					
					var total_descuento = this.controlador.dep('form_descuento').total('monto');
						
					if (total_descuento != '' && total_descuento!= null ) {
							
						total = ((total_detalle + total_concepto) - total_descuento);
						
					}else{
						
					total = total_detalle + total_concepto;

					}
						
				}else{
						
					var total_descuento = this.controlador.dep('form_descuento').total('monto');
						
					if (total_descuento != '' && total_descuento!= null ) {
							
						total = (total_detalle - total_descuento);
						
					}else{
						
					total = total_detalle;

					}
					
				}
				
				this.controlador.dep('form_total').ef('subtotal').set_estado(total);	
				alert (total);
								
			 }	
			
		   }
		}
		
		";
	}
}
?>
